
import java.util.prefs.Preferences;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author LiShixi
 */
public class TestPreferences {

    public static void main(String[] args) {
        TestPreferences regtray = new TestPreferences();
        String path = "filepath";
        regtray.saveFilePath("d:/test/test.dat");
        String readFilePath = regtray.readFilePath(path);
        System.out.println("readFilePath = " + readFilePath);

    }

    public String readFilePath(String path) {
        Preferences p = Preferences.userNodeForPackage(TestPreferences.class);
        String filepath = p.get(path, null);
        if (filepath != null) {
            System.out.println("filepath=" + filepath);

        }
        return filepath;
    }

    public void saveFilePath(String path) {
        Preferences p = Preferences.userNodeForPackage(TestPreferences.class);
        p.put("filepath", path);

    }

}
